package com.sudu.dao;

import com.sudu.domain.Attention;
import com.sudu.domain.Favorite;
import com.sudu.domain.Video;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface LikeDao {

    @Insert("insert into t_favorite(uid , vid , create_time) " +
            "values(#{uid},#{vid},#{createTime})")
    int saveFavorite (Favorite favorite) ;

    @Insert("insert into t_attention (uid , like_id , create_time) " +
            "values(#{uid},#{likeId},#{createTime})")
    int saveAttention (Attention attention) ;

    @Update("UPDATE t_favorite SET is_delete= #{newDelete}  WHERE uid = #{uid} and vid = #{vid}")
    int changeFavorite(int uid , int vid ,int newDelete) ;

    @Update("UPDATE t_attention SET is_delete= #{newDelete}  WHERE uid = #{uid} and like_id = #{likeId}")
    int changeAttention(int uid , int likeId , int newDelete) ;

    @Select("select * from t_favorite where uid = #{uid} and vid = #{vid} ")
    Favorite IfFavorite(int uid , int vid) ;

    @Select("select * from t_attention where uid = #{uid} and like_id = #{likeId} ")
    Attention IfAttention(int uid , int likeId) ;

    @Select("select like_id from t_attention where uid = #{uid} and is_delete = 1")
    List<Integer> selectUidNum(int uid) ;

    @Select("select uid from t_attention where like_id = #{uid} and is_delete = 1")
    List<Integer> selectLikeIdNum(int uid) ;

    @Select("select vid from t_favorite where uid = #{uid} and is_delete = 1")
    int[] selectVidByUid(int uid) ;
}
